package org.example.springboot.dao;

import org.apache.ibatis.annotations.*;
import org.example.springboot.model.InBound;
import org.example.springboot.model.Products;

import java.util.List;
@Mapper
public interface InBoundMapper {

    @Insert("insert into inbound(product_name, model_number, supplier_name,quantity,totalAmount,in_time,in_order_id) values (#{productName},#{modelNumber}, #{supplierName},#{quantity},#{totalAmount},#{inTime},#{inOrderId})")
    int insertInBound(@Param("productName") String productName, @Param("modelNumber") String modelNumber,@Param("supplierName") String supplierName,@Param("quantity") String quantity,@Param("totalAmount") String totalAmount,@Param("inTime") String inTime,@Param("inOrderId") String inOrderId);

    @Select("select * from inbound")
    List<InBound> getAllInBound();

    @Select("select * from inbound where id = #{id}")
    InBound getInBoundById(@Param("id")int id);

    @Select("select * from inbound " + "where product_name like CONCAT('%', #{keyword}, '%') " + "or model_number like CONCAT('%', #{keyword}, '%')"+ "or supplier_name like CONCAT('%', #{keyword}, '%')"+ "or in_time like CONCAT('%', #{keyword}, '%')"+ "or in_order_id like CONCAT('%', #{keyword}, '%')")
    List<InBound> findInBoundByKeyword(@Param("keyword")String keyword);

    @Delete("delete from inbound where id = #{id}")
    void deleteInBoundById(@Param("id")int id);

}
